/******************************************
* 深度
*********************************************/

#include<stdio.h>

int main(){
    char buf;
    int cur,max;
    cur = max = 0;
    while( '\n' != ( buf = getchar())  ){
        if(buf == '('){cur++;if(cur>max)max=cur;}
        if(buf == ')')cur--;
    }
    printf("%d\n",max);
    return 0;
}